package com.erp.app.catalog.catgroup.vo;

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;

import com.erp.app.catalog.catgroup.dao.CatalogGroupDAO;
import com.erp.app.catalog.catgroup.pk.CatalogGroupPK;
import com.erp.app.common.select.beans.SelectDelegate;
import com.erp.app.common.ProjectConstants;

import com.erp.framework.model.pk.SimpleSearchMaintStylePk;
import com.erp.framework.model.vo.SimpleSearchMaintStyleVo;
import com.erp.framework.model.vo.SimpleBaseVo;

import com.erp.framework.model.vo.ChildList;
import com.erp.framework.exceptions.FindRecordException;
import com.erp.framework.util.CommonUtil;

public class CatalogGroupVO extends SimpleSearchMaintStyleVo{

	protected  void setChildTypesName() {
		this.childTypesName=new String[1];
		this.childTypesName[0]="com.erp.app.catalog.catgroup.vo.CatalogGroupVO";
	}

	protected void setTableSchemaName() {
		this.tableSchemaName="com.erp.app.admin.accessRight.schema.AccessRightHdrSchema";
	}

	protected  void setChildTableSchemaNames() {
	}

	protected void setDaoName() {
		this.daoName="com.erp.app.catalog.catgroup.dao.CatalogGroupDAO";
	}

	protected void setBizLogicName() {
		this.bizLogicName = "com.erp.app.catalog.catgroup.bizLogic.CatalogGroupBizLogic";
	}

	public SimpleSearchMaintStylePk getSearchMaintStylePk() {
		return new CatalogGroupPK(l01nodid);
	}

	public String toString() {
		String colStr = "COL: {}\n";

		return "CatalogGroupVO.toString() is:\n" + colStr;
	}

    //This class is for security
    public  ChildList getCatalogGroupChildsList(String userId) throws FindRecordException{
    	ChildList  reitemList = new ChildList(CatalogGroupVO.class);
    	ChildList primaryItemList = null;
    	CatalogGroupDAO dao = new CatalogGroupDAO();
    	primaryItemList = (ChildList)dao.selectByParent((SimpleBaseVo) this);
    	SelectDelegate sdg = new SelectDelegate();
    	ArrayList list = sdg.selectOneList("SELECT  NODE_ID FROM T_CATALOG_SECURITY_DTL WHERE USER_CODE = '" + userId + "' ");
    	HashMap listMap = new HashMap();
    	if (list.size() == 0) return primaryItemList;
    	for(int i = 0; i < list.size(); i++){
    		listMap.put(CommonUtil.bigDecimalToStr((BigDecimal)list.get(i)), CommonUtil.bigDecimalToStr((BigDecimal)list.get(i)));
    	}
    	if(listMap.size() > 0){
    		for(int j = 0; j < primaryItemList.size(); j++){
    			CatalogGroupVO catalogVO = null;
        		catalogVO = (CatalogGroupVO) primaryItemList.get(j);
        		if(catalogVO != null
        				&& CommonUtil.isEmpty(CommonUtil.nullToString(listMap.get(CommonUtil.bigDecimalToStr(catalogVO.getL01nodid())))) 
        				&& ProjectConstants.CATALOG_BWR_SHOW.equals(catalogVO.getL01bwr())
        		){
        			reitemList.add(catalogVO);
        		}
        		catalogVO = null;
        	}
    	}
    	return reitemList;
    }

    private BigDecimal l01nodid;
    private String l01dsc;
    private BigDecimal l01imgid;
    private BigDecimal l01lvl;
    private String l01typ;
    private BigDecimal l01catid;
    private String l01crecomcod;
    private BigDecimal l01audid;
    private BigDecimal l01act;
    private String userId;
    private String l01bwr;
	
    public String getL01bwr() {
		return l01bwr;
	}

	public void setL01bwr(String l01bwr) {
		this.l01bwr = l01bwr;
	}

	public BigDecimal getL01act() {
        return l01act;
    }

    public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public void setL01act(BigDecimal l01act) {
        this.l01act = l01act;
    }

    public BigDecimal getL01audid() {
        return l01audid;
    }

    public void setL01audid(BigDecimal l01audid) {
        this.l01audid = l01audid;
    }

    public BigDecimal getL01catid() {
        return l01catid;
    }

    public void setL01catid(BigDecimal l01catid) {
        this.l01catid = l01catid;
    }


    public String getL01crecomcod() {
        return l01crecomcod;
    }

    public void setL01crecomcod(String l01crecomcod) {
        this.l01crecomcod = l01crecomcod;
    }

    public String getL01dsc() {
        return l01dsc;
    }

    public void setL01dsc(String l01dsc) {
        this.l01dsc = l01dsc;
    }

    public BigDecimal getL01imgid() {
        return l01imgid;
    }

    public void setL01imgid(BigDecimal l01imgid) {
        this.l01imgid = l01imgid;
    }

    public BigDecimal getL01lvl() {
        return l01lvl;
    }

    public void setL01lvl(BigDecimal l01lvl) {
        this.l01lvl = l01lvl;
    }

    public BigDecimal getL01nodid() {
        return l01nodid;
    }

    public void setL01nodid(BigDecimal l01nodid) {
        this.l01nodid = l01nodid;
    }

    public String getL01typ() {
        return l01typ;
    }

    public void setL01typ(String l01typ) {
        this.l01typ = l01typ;
    }
}
